package com.qzimp.fujiancuo.mapper;

import com.mybatisflex.core.BaseMapper;
import com.qzimp.fujiancuo.entity.Event;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *  映射层。
 *
 * @author 吴宗波
 * @since 2024-11-21
 */
public interface EventMapper extends BaseMapper<Event> {
    @Insert("INSERT INTO tb_event (name, happen_time, description, cuo_id) VALUES (#{event.name}, #{event.happenTime}, #{event.description}, #{event.cuoId})")
    int insertEvent(@Param("event") Event event);

    @Select("SELECT e.* FROM tb_event e JOIN tb_cuo c ON e.cuo_id=c.id WHERE c.id = #{id}")
    List<Event> queryByCuoId(Integer id);
}
